<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/static/commons/taglibs.jsp"%>
<%@ include file="/static/commons/meta.jsp"%>
<%@ include file="/static/commons/jquery-easyui.jsp"%>
<html >
	 <head>
 		<title>${title }</title>
 		 <link rel="stylesheet" href="${ctx }/static/styles/basic/basic.css" />
		 <link rel="stylesheet" href="${ctx }/static/styles/frame/main.css" />
		 <link rel="stylesheet" href="${ctx }/static/styles/frame/searchBtn.css" />
		 <link rel="stylesheet" href="${ctx }/static/styles/frame/searchCondition.css" />
	    <!-- js -->
 		<script language="JavaScript" src="${ctx}/static/scripts/check_all.js"></script>
 		<script language="JavaScript" src="${ctx}/static/scripts/set_select.js"></script>
 		<script language="JavaScript" src="${ctx}/static/scripts/waiting.js"></script>
 		<script language="JavaScript" src="${ctx}/static/scripts/crud.js"></script>
 		<script language="JavaScript" src="${ctx}/static/scripts/util.js"></script>
		
	</head>
  <body onload="init()">
		<form action="${ctx}/role/list" method="post">
  			<input type="hidden" name="RequestVerificationToken" value="${RequestVerificationToken}" />
			<div class="width_100 group_box">
				<div class="group_search width_100">
					<vvise:searchInput id="userName" name="p_roleName" displayText="角色名称" />
               	 	<div class="clear_both"></div>
				</div>
				<vvise:funMenu menuId="${menuId}" />
			</div>
        </form>
        <div class="listFrame">
        	<iframe name="listFrame" id="listFrame" frameBorder="0"
				scrolling="auto" style="width: 100%;height:100%;"></iframe>
        </div>
	</body>
	<script language="javaScript">
  		var headers = {};
		headers['__RequestVerificationToken'] = "${RequestVerificationToken}";
			//回车事件
		document.onkeydown = keyKistener;
		function keyKistener(e){
			e = e ? e:event;
			if(e.keyCode == 13){
				try{
					search();
				}catch(e){}
			}
		}
		function init(){
			set_iframe_h();
			$(window).resize(function(){
				set_iframe_h();
			});
			search();
			$('.easyui-combobox').combobox();
		}
		//设置ifream 高度
		function set_iframe_h(){
			var win_height  = $(window).height();
			var func_line_h = $('.group_box').outerHeight(true);
			var list_height = win_height - func_line_h;
			$('.listFrame').css('height',list_height-10);
		}
		function search(){
			waiting();
			document.forms[0].target = "listFrame";
			document.forms[0].submit();
		}
		
			function create(roleId){
				if(parent.isEmpty(roleId))
					roleId = "";
					
				var pp = parent;
				doCreate("角色信息",pp.width1,180,"${ctx}/role/edit?p_roleId="+roleId);
			}
			
			function save(){
				var pp = parent;
				var editFrame = pp.winFrame;
				var roleId = editFrame.$('#roleId').val();
				var roleName = editFrame.$('#roleName').val();
				
				
				if(!pp.validData("roleName","请输入角色名称！"))
					return;
					var flag = executeAjaxBySync('${ctx}/role/checkName','p_roleName='+roleName+"&p_roleId="+roleId);
				if(flag == 'ERROR'){
					pp.alertMsg('该角色名称已经存在，请重新输入','warning',function(){
						try{
						 	editFrame.$('#roleName').focus();
					 	 }catch(e){}
					});
					return;
				}
				
				doSave("${ctx}/role/save",roleId);
			}
			
			function view(roleId){
				var pp = parent;
				doView("角色信息",pp.width1,180,"${ctx}/role/edit?p_roleId="+roleId+"&view=view");
			}
			
			function updateStatus(flag){
				var pp = parent;
				var ids = "";
				var ecForm = listFrame.document.all.ec;
				if(!checkSelect(ecForm.id,true))
					return;
				ids = get_checkbox_values(ecForm.id,',');
				
				var optMsg = "状态修改成功！";
				var msgVal = "启用";
				if(flag == 2)
					msgVal = "停用";
				if(flag == 3){
					msgVal = "删除";
					optMsg = "删除成功！";
				}
				pp.confirmMsg("确定要"+ msgVal +"吗？",function(){
					var urls = "${ctx}/role/updateStatus";
				    var params = "ids="+ids;
				    params += "&status="+flag;
				    executeAjax(urls,params,function(data){
					    if(data != 'error'){
					    	pp.$.messager.alert('操作提示', optMsg, "info",function(){
					    		listRefresh();
					    	});
						}else{
							pp.$.messager.alert('操作提示',"操作失败！","error");
						}
				    });
				});
		}
		</script>
</html>